.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 20px;
  font-weight: 600;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: 0.5px;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  &:hover::before {
    opacity: 1;
  }

  &:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none !important;
  }

  &.loading {
    cursor: wait;
  }
}

.primary {
  background: var(--theme-primary-gradient);
  color: #fff;
  box-shadow: 0 4px 15px var(--theme-primary-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  border: none;
  position: relative;

  &::after {
  content: ''; /* 伪元素必须要有content */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* 在伪元素上设置“边框”，实际上是覆盖一层透明背景 */
  border: 2px solid rgba(255, 255, 255, 1);
  border-radius: 9999px; /* 圆角与按钮一致 */
  box-sizing: border-box; /* 确保边框向内绘制，不影响尺寸 */
  pointer-events: none; /* 让鼠标事件可以穿透伪元素，点击到下面的按钮 */
}

  &:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--theme-primary-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    background: var(--theme-primary-gradient);
  }

  &:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 10px var(--theme-primary-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

.secondary {
  background: var(--theme-secondary-gradient);
  color: var(--theme-secondary-text, #6B46C1);
  box-shadow: 0 4px 15px var(--theme-secondary-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.4);

  &:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--theme-secondary-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    background: var(--theme-secondary-gradient);
  }

  &:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 10px var(--theme-secondary-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
}

.outline {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
  color: var(--theme-outline-main, #FF9ACD);
  border: 2px solid transparent;
  background-clip: padding-box;
  position: relative;

  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    padding: 2px;
    background: var(--theme-outline-border);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: xor;
    -webkit-mask-composite: xor;
    z-index: -1;
  }

  &:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--theme-primary-shadow);
    background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.9) 100%);
  }

  &:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 10px var(--theme-primary-shadow);
  }
}

.small {
  padding: 6px 16px;
  font-size: 12px;
  height: 32px;
  border-radius: 16px;
}

.medium {
  padding: 10px 24px;
  font-size: 14px;
  height: 40px;
  border-radius: 20px;
}

.large {
  padding: 14px 32px;
  font-size: 16px;
  height: 48px;
  border-radius: 24px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 主题特定颜色变量 */
.theme-pink {
  --theme-secondary-text: #6B46C1;
  --theme-outline-main: #FF9ACD;
}

.theme-blue {
  --theme-secondary-text: #2C5282;
  --theme-outline-main: #4682B4;
}

.theme-purple {
  --theme-secondary-text: #6B46C1;
  --theme-outline-main: #9370DB;
}

/* 添加闪烁动画效果 */
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.button.glow {
  &::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--theme-glow-gradient);
    background-size: 400% 400%;
    border-radius: inherit;
    z-index: -1;
    animation: shimmer 3s ease infinite;
    opacity: 0.7;
  }
}